package club.ruanx.movie.controller;

import club.ruanx.bean.PageBean;
import club.ruanx.movie.entity.nosql.OperateLog;
import club.ruanx.movie.repository.mongodb.OperateLogRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 阮胜
 * @date 2018/10/30 14:45
 */
@RestController
@RequestMapping("/log")
public class OperatorLogController {
    private final OperateLogRepository operateLogRepository;

    public OperatorLogController(OperateLogRepository operateLogRepository) {
        this.operateLogRepository = operateLogRepository;
    }

    @GetMapping("/list")
    public List<OperateLog> list(PageBean pageBean) {
        return operateLogRepository.findAll(pageBean.toPageable()).getContent();
    }

    @PostMapping("/save")
    public OperateLog save(OperateLog operateLog) {
        return operateLogRepository.save(operateLog);
    }
}
